# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName : zsj.py
# @Time     : 2024/4/15 21:32
# @Author   : Robot-Zsj
"""
description:

i:
1,2,3,4,5,6,7,8,9
4
3

o:
13
"""
nums = list(map(int, input().split(",")))
jump = int(input())
left = int(input())


def sumOfLeft(nums, jump, left):
    start = 1

    while len(nums) > left:
        start += jump

        start %= len(nums)

        nums.pop(start)

    return sum(nums)


print(sumOfLeft(nums, jump, left))


